using UnityEngine;
using UnityEngine.UI;

public class AchieveItem : MonoBehaviour
{
	[SerializeField]
	private Image[] backgrounds;

	public Image icon;

	public Image prizeItem;

	public Text achieveName;

	public Text description;

	public Text progress;

	public GameObject takeRewardBtn;

	public Image achieveIcon;

	public Text finishFlag;

	public AchieveInfo achieveInfo
	{
		get;
		set;
	}

	public AchieveSubject parentPanel
	{
		get;
		set;
	}

	public Color backGround
	{
		set
		{
			for (int i = 0; i < backgrounds.Length; i++)
			{
				backgrounds[i].color = value;
			}
		}
	}

	public bool gray
	{
		set
		{
			if (value)
			{
				backGround = Color.gray;
				icon.transform.Find("BG").GetComponent<Image>().color = Color.gray;
				achieveName.color = Color.gray;
				enableGift = false;
				achieveIcon.color = Color.gray;
			}
			else
			{
				backGround = Color.white;
				icon.color = Color.white;
				achieveName.color = Color.white;
				icon.transform.Find("BG").GetComponent<Image>().color = Color.white;
				enableGift = true;
				achieveIcon.color = Color.white;
			}
		}
	}

	private bool enableGift
	{
		set
		{
			takeRewardBtn.GetComponent<Button>().interactable = value;
			takeRewardBtn.transform.parent.GetComponent<Animator>().enabled = value;
			takeRewardBtn.transform.parent.Find("Light").gameObject.SetActive(value);
		}
	}

	public void TakeReward()
	{
		if (achieveInfo != null)
		{
			finishFlag.gameObject.SetActive(value: true);
			takeRewardBtn.transform.parent.gameObject.SetActive(value: false);
			parentPanel.OpenGetItemWnd(achieveInfo.prizeItemId, achieveInfo.prizeItemCount, delegate
			{
				ConstantData.chips += achieveInfo.prizeChips;
				if (achieveInfo.prizeItemId > 0)
				{
					ItemMgr.instance.AddItem(achieveInfo.prizeItemId, achieveInfo.prizeItemCount);
				}
				ConstantData.achieveRecords.TakeReward(achieveInfo.id);
			});
		}
	}
}
